<template>
  <div class="right-top">
    <div class="title">
      <div class="title-left">
        <!--<span>
          <img src="../../assets/par.png" alt="" />
        </span>-->
        <span class="name">商邦交易金额</span>
      </div>
      <div class="title-right">{{ shangbangData.amount }}</div>
    </div>
    <div class="table">
      <span>排序</span>
      <span>时间</span>
      <span>行业</span>
      <span>金额</span>
    </div>
    <div class="table-two" ref="tableColumn">
      <div
        class="table-column"
        v-for="(item, index) in shangbangData.cate_list"
        :key="index"
        :class="{ newBgc: (index + 1) % 2 == 0 }"
      >
        <span>{{ index + 1 }}</span>
        <span>{{ item.time }}</span>
        <span>{{ item.title }}</span>
        <span>{{ item.amount }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    shangbangData: {
      type: Object,
      default: () => {},
    },
  },
  mounted() {
    setInterval(() => {
      const scrollTop = this.$refs.tableColumn.scrollTop;
      const scrollHeight = this.$refs.tableColumn.scrollHeight;
      const clientHeight = this.$refs.tableColumn.clientHeight;

      if (clientHeight >= scrollHeight - scrollTop) {
        this.$refs.tableColumn.scrollTop = 0;
      } else {
        this.$refs.tableColumn.scrollTop += 1;
      }
    }, 50);
  },
};
</script>

<style scoped lang="less">
.right-top {
  height: 100%;
  overflow: hidden;
  margin: 0 20px;
  //background-color: rgb(6, 26, 54);
  .title {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    margin: 16px 20px 10px;
    .title-left {
      font-size: 20px;
      span:first-child {
        display: flex;
        align-items: center;
      }
      .name::before {
        content: "";
        width: 20px;
        height: 20px;
        background-color: url("../../assets/par.png");
      }
    }
    .title-right {
      font-weight: bold;
    }
  }
  .table {
    display: flex;
    background-color: rgba(241, 241, 241, 0.06);
    height: 36px;
    line-height: 36px;
    span {
      font-size: 16px;
      flex: 1;
      color: #06b2f1;
      text-align: center;
    }
  }
  .table-two {
    height: calc(100% - 100px);
    overflow: hidden; //auto
    .table-column {
      display: flex;
      height: 30px;
      line-height: 30px;
      padding: 2px 0;
      font-size: 14px;

      span {
        flex: 1;
        text-align: center;
      }
    }
    .newBgc {
      background: rgba(177, 219, 255, 0.5);
    }
  }
}
</style>
